package sword;

/**
 * @Author: 海琳琦
 * @Date: 2022/5/25 15:56
 */
public class Title30 {

    class Node {
        int val;
        Node next;
        int min;

        public Node(int val, Node next, int min) {
            this.val = val;
            this.next = next;
            this.min = min;
        }
    }

    private Node head;

    /** initialize your data structure here. */
    public Title30() {
    }

    public void push(int x) {
        if (head == null) {
            head = new Node(x, null, x);
        }else{
            head = new Node(x, head, Math.min(x, min()));
        }
    }

    public void pop() {
        head = head.next;
    }

    public int top() {
        return head.val;
    }

    public int min() {
        return head.min;
    }

}
